﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using Gift.DAL;
using Gift.Model;
using Gift.Model.ENUM;

namespace WebSite.admin.warehouse
{
    public partial class warehouseGoodsRealyCount : BaseAdmin
    {
        tbWarehouseGoodsInventoryDetail oWarehouseGoodsInventoryDetail;
        readonly DALWarehouseGoodsInventory theWarehouseGoodsInventory = new DALWarehouseGoodsInventory();
        readonly DALWarehouseGoodsInventoryDetail theWarehouseGoodsInventoryDetail = new DALWarehouseGoodsInventoryDetail();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                base.ValidateLoginRule(Gift.Model.ENUM.ERule.WarehouseGoodsInventoryManager);
                this.BuildForm();
            }
        }

        void BuildForm()
        {
            oWarehouseGoodsInventoryDetail = theWarehouseGoodsInventoryDetail.GetModel(int.Parse(Request.QueryString["id"]));
            if (oWarehouseGoodsInventoryDetail != null)
            {
                this.lblProName.Text = oWarehouseGoodsInventoryDetail.goodsName;
                this.lblGoodsBatchNo.Text = oWarehouseGoodsInventoryDetail.goodsBatchNo;
            }
        }



        protected void btnSubmitForm1_Click(object sender, EventArgs e)
        {
            oWarehouseGoodsInventoryDetail = theWarehouseGoodsInventoryDetail.GetModel(int.Parse(Request.QueryString["id"]));
            oWarehouseGoodsInventoryDetail.realyCount = int.Parse(this.txtGoodsRealyCount.Text);
            oWarehouseGoodsInventoryDetail.differenceCount = oWarehouseGoodsInventoryDetail.paperCount - oWarehouseGoodsInventoryDetail.realyCount;

            if (theWarehouseGoodsInventoryDetail.Update(oWarehouseGoodsInventoryDetail))
            {
                ExtAspNet.Alert.Show("保存成功！");
                ExtAspNet.PageContext.RegisterStartupScript(ExtAspNet.ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                ExtAspNet.Alert.Show("保存失败！");
            }
        }
    }
}